<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

Route::get('/', function () {
    return view('welcome');
});

Route::group(['prefix' => 'admin'], function () {
    Route::auth();
});


Route::group(['prefix' => 'admin', 'namespace' => 'Admin','middleware' => 'auth'], function () {
    Route::get('/', 'IndexController@index');
});

Route::group(['namespace' => 'Admin\Shop', 'prefix' => 'admin','middleware' => 'auth'], function () {
    //品牌管理
    Route::post('upload', 'BrandController@upload');
    
    Route::group([ 'prefix' => 'brand'], function () {
        Route::patch('sort_order', 'BrandController@sort_order');
    	Route::patch('is_something', 'BrandController@is_something');

    });
    Route::resource('brand', 'BrandController');
    //Route::post('/','BrandController@');

    //栏目管理
    Route::group(['prefix' => 'category'],function (){
        Route::patch('sort_order', 'CategoryController@sort_order');
        Route::patch('is_something', 'CategoryController@is_something');
    });
    Route::resource('category', 'CategoryController');
    //商品管理
    Route::group(['prefix' => 'product'], function () {
        Route::patch('change_stock', 'ProductController@change_stock');
        Route::delete('destroy_checked', 'ProductController@destroy_checked');
        Route::delete('destroy_gallery', 'ProductController@destroy_gallery');
        Route::patch('is_something', 'ProductController@is_something');

        //回收站
        Route::get('trash', 'ProductController@trash');
        Route::get('/{product}/restore', 'ProductController@restore');
        Route::delete('/{product}/force_destroy', 'ProductController@force_destroy');
        Route::delete('force_destroy_checked', 'ProductController@force_destroy_checked');
        Route::post('restore_checked', 'ProductController@restore_checked');
    });
    Route::resource('product', 'ProductController');
});
/**
 * System 系统设置
 */
Route::get('/', function () {
    return redirect("/System/");
});

Route::group(['namespace' => 'Admin\System', 'prefix' => 'system', 'middleware' => 'auth'], function () {
    /*
    * 微信控制器
    */
    Route::get('/wechatapi', 'WXController@index');
    //上传
    Route::post('/upload_icon', 'FileController@upload_icon');
    Route::post('/upload', 'FileController@upload');
    //Route::get('123', 'FileController@index');
});
/*
 * 微信商城
 */
Route::group([ 'namespace' => 'Home'/* , 'middleware' => 'wechat'*/], function () {
    Route::get('/', 'WechatController@index');
    Route::get('/product/{product}', 'ProductController@show');
    Route::get('/list/{category}', 'ProductController@li');
    Route::get('category', 'ProductController@category');
    Route::get('customer', 'CustomerController@index');
    //购物车
    Route::group(['prefix' => 'cart'], function () {
        Route::get('/', 'CartController@index');
        Route::post('/', 'CartController@store');
        Route::delete('/', 'CartController@destroy');
        Route::patch('/', 'CartController@change_num');
    });
    //搜索
    Route::get('/search', 'ProductController@search');

    //订单
    Route::group(['prefix' => 'order'], function () {
        Route::get('/', 'OrderController@index');
        //下单
        Route::get('checkout', 'OrderController@checkout');

        //生成订单,支付
        Route::post('/', 'OrderController@store');
        Route::get('pay/{id}', 'OrderController@show_pay');

        //删除订单
        Route::delete('{id}', 'OrderController@destroy');

        //我的订单
        Route::get('{id}', 'OrderController@show');
    });
    //地址管理
    Route::group(['prefix' => 'address'], function () {
        //管理地址
        Route::get('/manage', 'AddressController@manage');
        //改变默认地址
        Route::patch('/', 'AddressController@default_address');
    });
    Route::resource('address', 'AddressController');

    //Api接口
    Route::any('api', 'ApiController@serve');
    //Route::get('hot','ApiController@is_hot');

});
/*
 * JSW-AUTH
 */
//Route::get('auth', 'AuthenticateController@authenticate');
//Route::group([ 'namespace' => 'Admin','prefix' => 'api'/*, 'middleware' => 'jwt.auth'*/], function () {
//
//});


Route::get('/home', 'HomeController@index');

